<template>
  <div class="uplaodBox">
    <a-row class="head">
      <div style="cursor: pointer" @click="goback">
        <a-icon type="left" />
        <div class="left2">返回</div>
      </div>
      <a-col class="title">
        <strong>导入专项附加扣除累计</strong>
      </a-col>
    </a-row>
    <div class="ant-upload-select-text-box" style="padding-top: 24px">
      <a-upload ref="upload" :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload">
        <img :src="uploadImg" style="width: 139px; height: 106px" />
        <div class="ant-modal-body">
          <div style="font-size: 12px; color: #666">点击添加文件或将文件拖拽到此处</div>
          <div style="font-size: 12px; color: #999">(文件大小不超过5M)</div>
        </div>
      </a-upload>
    </div>
    <div class="tipBox">
      <a-row style="color: #252525; font-size: 16px; font-weight: 500; padding-bottom: 10px"> 温馨提示 </a-row>
      <a-row>
        <a-col :span="12">
          <div>1、建议直接导入税务系统中下载的“正常工资薪金所得报表”，系统将自动读取专项附加扣除累计。</div>
          <div>
            2、您也可以通过标准模板进行导入，点击
            <span class="primary_color" @click="download" style="font-size: 12px; cursor: pointer"> 下载标准模板 </span>
          </div>
        </a-col>
      </a-row>
    </div>
    <a-modal v-model="dialogFailVisible" title="未成功名单" width="800px" @ok="handleFailClose">
      <a-table :row-key="(d) => d.id" :columns="columns" :data-source="Faildata" :pagination="false" />
    </a-modal>
  </div>
</template>
<script>
import UploadMixin from "xqjr-plugin-common/UploadOrExport/uploadMixin";
const mixin = UploadMixin();
const columns = [
  {
    title: "行号",
    dataIndex: "id",
    key: "id"
  },
  {
    title: "姓名",
    dataIndex: "name",
    key: "name"
  },
  {
    title: "原因",
    dataIndex: "failureReason",
    key: "failureReason"
  }
];

export default {
  mixins: [mixin],
  data() {
    return {
      columns,
      params: {
        templateName: "cumulativeDeductionOfSpecialAdditionalItems.xlsx"
      },
      url: `/salary/api/v1/excel/template/download`,
      excelName: "专项附加扣除累计导入模板.xlsx",
      uploadImg: require("@/assets/img/uploadImg.png")
    };
  },
  computed: {
    month() {
      return this.$route.query.month;
    },
    year() {
      return this.$route.query.year;
    },
    companyId() {
      return this.$store.state.hr.companyId;
    }
  },
  created() {
    this.action = `/salary/api/v1/employeeSalaries/importSpecialAdditionalItems?companyId=${this.companyId}&force=false&month=${this.month}&year=${this.year}`;
  },
  methods: {
    handleUploadError() {
      this.$message.warning("没有文件");
    }
  }
};
</script>
